package com.itheima.pinda.authority.biz.service.common.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.pinda.authority.biz.dao.common.OptLogMapper;
import com.itheima.pinda.authority.biz.service.common.OptLogService;
import com.itheima.pinda.authority.entity.common.OptLog;
import com.itheima.pinda.dozer.DozerUtils;
import com.itheima.pinda.log.entity.OptLogDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 业务实现类
 * 操作日志
 */
@Slf4j
@Service
public class OptLogServiceImpl extends ServiceImpl<OptLogMapper, OptLog> implements OptLogService {

    @Resource
    DozerUtils dozerUtils;

    /**
     * 保存用户的操作日志
     *
     * @param optLogDTO 操作日志
     * @return
     */
    @Override
    public boolean save(OptLogDTO optLogDTO) {
        // int count = baseMapper.insert(dozerUtils.map(optLogDTO, OptLog.class));
        /**
         * super.save(xx) 就是封装了一层 baseMapper.insert(xx), 他们两的返回值不同, 一个是count影响行数, 一个是true/false
         *. @Override
         *. public boolean save(T entity) {
         *.     return retBool(baseMapper.insert(entity));
         *. }
         */
        boolean save = super.save(dozerUtils.map(optLogDTO, OptLog.class));
        return save;
    }
}